#ifndef STATSTRACKS_H
#define STATSTRACKS_H

#include "controls/rotatingwidget.h"

class GPS_track;
class FTMultiButton;
class FTLabel;
class FTGraph;
class FTComboBox;

class StatsTracks : public RotatingWidget
{
    Q_OBJECT
public:
    enum graph_type { altitude = 0,
                 speed = 1,
                 bearing = 2,
                 overview = 3,
                 numbers = 4};
    explicit StatsTracks(const GPS_track* t = NULL);

    // Its mandatory to call this method to set a track...
    // or pass a valid track to the constructor!
    void setTrack( const GPS_track* );


signals:

public slots:
    // Switch to a different view, slot for direct link with the selector
    void setView( int );
    // Slot to change the currently selected leg
    void selectLeg(int);
    // Force an update of the data to the views
    void updateView();

private:
   // Build the widgets
    void buildMain();

    // Update the views:
    void updateAltitude();
    void updateSpeed();
    void updateBearing();
    void updateOverview();
    void updateNumbers();

    // Store the track
    const GPS_track* track;

    // Widgets
    QStackedWidget* pages;
    QWidget* stats;
    FTLabel* stats_title;
    FTLabel* stats_start_date;
    FTLabel* stats_end_date;
    FTLabel* stats_altitude;
    FTLabel* stats_speed;
    FTLabel* stats_length;
    FTLabel* stats_full_track;
    FTMultiButton* selector;
    FTGraph* graph;
    FTComboBox* leg_selector;

    // The currently selected leg (-1 for all toghether)
    int selectedLeg;
    // Active view
    StatsTracks::graph_type currentGraph;

    QLayout* createHorizontal();
    QLayout* createVertical();

};

#endif // STATSTRACKS_H
